from django.contrib.auth.models import User
from django.db import models

# Create your models here.

from system.models import Department

class Student(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=10, verbose_name='学生姓名')
    sex = models.IntegerField()
    phone = models.CharField(max_length=11)
    family_phone = models.CharField(max_length=11, verbose_name='家长手机号')
    relations = models.CharField(max_length=30, verbose_name='亲子关系')
    address = models.CharField(max_length=100, verbose_name='学生地址')
    dormnumber = models.IntegerField(verbose_name='宿舍号')
    bednumber = models.IntegerField(verbose_name='床号')
    market = models.CharField(max_length=30, verbose_name='市场部')
    idcardnumber = models.CharField(max_length=20, verbose_name='身份证号', unique=True)
    cls = models.ForeignKey(to='Class', on_delete=models.SET_NULL, null=True)

    class Meta:
        db_table = 'student_info'


class Class(models.Model):
    name = models.CharField(max_length=10, verbose_name='班级的名称')
    school = models.ForeignKey(to=Department, on_delete=models.CASCADE, verbose_name='班级所属学院')


    def __str__(self):
        return self.name

    class Meta:
        db_table = 'class'
        ordering = ['-id']



